import Vue from 'vue'
import VueRouter from 'vue-router'
import routes from './routes'
Vue.use(VueRouter)
let originPush = VueRouter.prototype.push
VueRouter.prototype.push = function(location, resolve, reject) {
    if (resolve && reject) {
        originPush.call(this, location, resolve, reject)
    } else {
        originPush.call(this, location, () => {}, () => {})
    }
}
let router = new VueRouter({
    routes,
    scrollBehavior(to, from, savedPosition) { //路由跳转后返回到最上方
        return { y: 0 }
    }
})
router.beforeEach((to, from, next) => {
    next()
})
export default router